library(tidyverse)
library(tidycensus)American Community Survey 2010-2019
The purpose of this document is to clean and merge data from the 2010-2019 American Community Survey at the PUMA level.
# extract estimates for 2021
d_2021 <- get_acs(geography = "puma",
variables = c(medincome = "B19013_001"),
year = 2021,
survey = "acs1",
geometry = TRUE)
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======= | 11%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 18%
|
|============= | 18%
|
|============== | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|================ | 22%
|
|================ | 23%
|
|================= | 25%
|
|=================== | 27%
|
|==================== | 29%
|
|===================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|========================= | 36%
|
|========================== | 38%
|
|============================ | 39%
|
|============================ | 40%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|===================================== | 53%
|
|===================================== | 54%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================== | 57%
|
|========================================= | 58%
|
|========================================== | 61%
|
|=========================================== | 61%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 72%
|
|==================================================== | 74%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|========================================================= | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 86%
|
|============================================================= | 88%
|
|============================================================== | 89%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|======================================================================| 99%
|
|======================================================================| 100%
# loop through the years
for (y in 2010:2019) {
d_year <- paste0("d_", y)
d <- get_acs(geography = "puma",
variables = c(medincome = "B19013_001"),
state = "OH",
year = y,
survey = "acs1"
)
d <- d |>
mutate(year = y)
assign(d_year, d)
}# merge
d <- bind_rows(d_2010, d_2011, d_2012, d_2013, d_2014, d_2015, d_2016, d_2017, d_2018, d_2019)d |> filter(year == 2019) |>
select(GEOID, NAME, estimate, year) |>
head(20)| GEOID | NAME | estimate | year |
|---|---|---|---|
| 3900100 | Defiance, Williams, Henry & Paulding Counties PUMA; Ohio | 57863 | 2019 |
| 3900200 | Wood (South), Fulton & Lucas (Southwest) Counties–Bowling Green City PUMA; Ohio | 60034 | 2019 |
| 3900300 | Lucas (West) & Wood (North Central) Counties–Perrysburg, Sylvania & Maumee Cities PUMA; Ohio | 86302 | 2019 |
| 3900400 | Toledo City (West) PUMA, Ohio | 45375 | 2019 |
| 3900500 | Toledo City (East) PUMA, Ohio | 31173 | 2019 |
| 3900600 | Ottawa, Wood (Northeast) & Lucas (East) Counties–Oregon City PUMA; Ohio | 62346 | 2019 |
| 3900700 | Erie & Sandusky Counties PUMA, Ohio | 60400 | 2019 |
| 3900801 | Lorain County (North)–Elyria & Lorain Cities PUMA, Ohio | 40793 | 2019 |
| 3900802 | Lorain County (South)–Avon, Avon Lake & North Ridgeville Cities PUMA; Ohio | 77665 | 2019 |
| 3900901 | Cuyahoga County–Olmsted Township, Bay Village, North Olmsted & Westlake Cities PUMA; Ohio | 75359 | 2019 |
| 3900902 | Cuyahoga County (West)–Berea, Brook Park, Lakewood & Rocky River Cities PUMA; Ohio | 60578 | 2019 |
| 3900903 | Cuyahoga County (South)–Broadview Heights, North Royalton & Strongsville Cities PUMA; Ohio | 82788 | 2019 |
| 3900904 | Cuyahoga County (South Central)–Brooklyn, Parma, Parma Heights & Seven Hills Cities PUMA; Ohio | 57674 | 2019 |
| 3900905 | Cleveland City (West) PUMA, Ohio | 39438 | 2019 |
| 3900906 | Cleveland City (Central) PUMA, Ohio | 33062 | 2019 |
| 3900907 | Cuyahoga County (Southeast)–Bedford, Garfield Heights & Maple Heights Cities PUMA; Ohio | 46014 | 2019 |
| 3900908 | Cleveland City (East) & Bratenahl Village PUMA, Ohio | 28830 | 2019 |
| 3900909 | Cuyahoga County (Northeast)–Euclid, Cleveland Heights & South Euclid Cities PUMA; Ohio | 54567 | 2019 |
| 3900910 | Cuyahoga County (East)–Lyndhurst, Mayfield Heights, Shaker Heights & Solon Cities PUMA; Ohio | 73308 | 2019 |
| 3901000 | Lake County (West)–Eastlake, Wickliffe, Willoughby & Willowick Cities PUMA; Ohio | 62184 | 2019 |
d |> arrange(estimate) |>
select(GEOID, NAME, estimate, year) |>
head(10)| GEOID | NAME | estimate | year |
|---|---|---|---|
| 3900607 | PUMA 00607, Ohio | 18880 | 2011 |
| 3900908 | Cleveland City (East) & Bratenahl Village PUMA, Ohio | 21201 | 2012 |
| 3900607 | PUMA 00607, Ohio | 21313 | 2010 |
| 3900908 | Cleveland City (East) & Bratenahl Village PUMA, Ohio | 21368 | 2014 |
| 3900303 | PUMA 00303, Ohio | 21486 | 2010 |
| 3900908 | Cleveland City (East) & Bratenahl Village PUMA, Ohio | 21639 | 2013 |
| 3900303 | PUMA 00303, Ohio | 21753 | 2011 |
| 3904503 | PUMA 04503, Ohio | 21957 | 2010 |
| 3900608 | PUMA 00608, Ohio | 22020 | 2010 |
| 3900906 | Cleveland City (Central) PUMA, Ohio | 22257 | 2012 |
d |> arrange(-estimate) |>
select(GEOID, NAME, estimate, year) |>
head(10)| GEOID | NAME | estimate | year |
|---|---|---|---|
| 3905507 | Hamilton County (East)–Loveland, Montgomery Cities & Forestville PUMA; Ohio | 115160 | 2019 |
| 3904000 | Delaware County PUMA, Ohio | 107854 | 2019 |
| 3904000 | Delaware County PUMA, Ohio | 106933 | 2017 |
| 3905507 | Hamilton County (East)–Loveland, Montgomery Cities & Forestville PUMA; Ohio | 102977 | 2018 |
| 3904000 | Delaware County PUMA, Ohio | 101693 | 2016 |
| 3905401 | Butler County (Southeast)–Monroe City & Beckett Ridge PUMA, Ohio | 99963 | 2019 |
| 3904000 | Delaware County PUMA, Ohio | 99881 | 2018 |
| 3905507 | Hamilton County (East)–Loveland, Montgomery Cities & Forestville PUMA; Ohio | 99223 | 2016 |
| 3905401 | Butler County (Southeast)–Monroe City & Beckett Ridge PUMA, Ohio | 98848 | 2016 |
| 3905507 | Hamilton County (East)–Loveland, Montgomery Cities & Forestville PUMA; Ohio | 98787 | 2017 |
variables <- load_variables(year = 2017,
dataset = "acs1")
variables |>
head(20)| name | label | concept |
|---|---|---|
| B00001_001 | Estimate!!Total | UNWEIGHTED SAMPLE COUNT OF THE POPULATION |
| B00002_001 | Estimate!!Total | UNWEIGHTED SAMPLE HOUSING UNITS |
| B01001A_001 | Estimate!!Total | SEX BY AGE (WHITE ALONE) |
| B01001A_002 | Estimate!!Total!!Male | SEX BY AGE (WHITE ALONE) |
| B01001A_003 | Estimate!!Total!!Male!!Under 5 years | SEX BY AGE (WHITE ALONE) |
| B01001A_004 | Estimate!!Total!!Male!!5 to 9 years | SEX BY AGE (WHITE ALONE) |
| B01001A_005 | Estimate!!Total!!Male!!10 to 14 years | SEX BY AGE (WHITE ALONE) |
| B01001A_006 | Estimate!!Total!!Male!!15 to 17 years | SEX BY AGE (WHITE ALONE) |
| B01001A_007 | Estimate!!Total!!Male!!18 and 19 years | SEX BY AGE (WHITE ALONE) |
| B01001A_008 | Estimate!!Total!!Male!!20 to 24 years | SEX BY AGE (WHITE ALONE) |
| B01001A_009 | Estimate!!Total!!Male!!25 to 29 years | SEX BY AGE (WHITE ALONE) |
| B01001A_010 | Estimate!!Total!!Male!!30 to 34 years | SEX BY AGE (WHITE ALONE) |
| B01001A_011 | Estimate!!Total!!Male!!35 to 44 years | SEX BY AGE (WHITE ALONE) |
| B01001A_012 | Estimate!!Total!!Male!!45 to 54 years | SEX BY AGE (WHITE ALONE) |
| B01001A_013 | Estimate!!Total!!Male!!55 to 64 years | SEX BY AGE (WHITE ALONE) |
| B01001A_014 | Estimate!!Total!!Male!!65 to 74 years | SEX BY AGE (WHITE ALONE) |
| B01001A_015 | Estimate!!Total!!Male!!75 to 84 years | SEX BY AGE (WHITE ALONE) |
| B01001A_016 | Estimate!!Total!!Male!!85 years and over | SEX BY AGE (WHITE ALONE) |
| B01001A_017 | Estimate!!Total!!Female | SEX BY AGE (WHITE ALONE) |
| B01001A_018 | Estimate!!Total!!Female!!Under 5 years | SEX BY AGE (WHITE ALONE) |
library(mapview)
mapview(d_2021, zcol = "estimate")